﻿<UserControl 
    x:Class="TfsWorkbench.HierarchyUI.HierarchyObjects.HierarchyViewNode"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:UIElements="clr-namespace:TfsWorkbench.UIElements;assembly=TfsWorkbench.UIElements" 
    xmlns:HierarchyUI="clr-namespace:TfsWorkbench.HierarchyUI" 
    xmlns:HierarchyObjects="clr-namespace:TfsWorkbench.HierarchyUI.HierarchyObjects" 
    mc:Ignorable="d" 
    d:DesignHeight="75" 
    d:DesignWidth="165"
    Name="PART_ControlBase"
    Cursor="{x:Static UIElements:CustomCursors.Hand}"
    >
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/TfsWorkbench.UIElements;Component/Resources/CommandButtonStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid DataContext="{Binding ElementName=PART_ControlBase, Path=HierarchyView}">
        <Grid.ToolTip>
            <StackPanel HorizontalAlignment="Center">
                <TextBlock Text="{Binding Path=ViewMap.Title}" FontWeight="Bold" />
                <TextBlock Text="{Binding Path=ViewMap.Description}" FontStyle="Italic" />
                <TextBlock Text="{Binding Path=ViewMapDetail}" />
            </StackPanel>
        </Grid.ToolTip>
        <Grid.ContextMenu>
            <HierarchyObjects:HierarchyViewContextMenu
                HierarchyView="{Binding}"
                >
                <MenuItem
    				CommandParameter="{Binding Path=ChildCreationParameters}" 
    				Command="{x:Static HierarchyUI:LocalCommandLibrary.AddChildItemCommand}"
    				CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"
                    >
                    <MenuItem.Icon>
                        <ContentControl Template="{StaticResource AddIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                    </MenuItem.Icon>
                    <MenuItem.Header>
                        <TextBlock FontWeight="Bold">
                            <Run Text="Add New:" />
                            <TextBlock Text="{Binding Path=ViewMap.ChildType}" />
                        </TextBlock>
                    </MenuItem.Header>
                </MenuItem>
                <MenuItem
                    Command="{x:Static HierarchyUI:LocalCommandLibrary.FilterToViewCommand}"
                    CommandParameter="{Binding Path=ViewMap.Title}"
                    CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"
                    >
                    <MenuItem.Icon>
                        <ContentControl Template="{StaticResource FilterIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem
    				CommandParameter="{Binding Path=ViewMap}" 
    				Command="{x:Static HierarchyUI:LocalCommandLibrary.EditViewCommand}"
    				CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"
                    >
                    <MenuItem.Icon>
                        <ContentControl Template="{StaticResource EditIconTemplate}" Style="{StaticResource MenuIconStyle}" />
                    </MenuItem.Icon>
                </MenuItem>
            </HierarchyObjects:HierarchyViewContextMenu>
        </Grid.ContextMenu>
        <Border
            BorderBrush="Black"
            BorderThickness="1"
            Background="LightBlue"
            CornerRadius="30"
            Padding="5"
            >
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                <TextBlock 
                    Text="{Binding Path=ViewMap.Title}" 
                    TextWrapping="Wrap"
                    TextTrimming="CharacterEllipsis"
                    HorizontalAlignment="Center"
                    TextAlignment="Center"
                    />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>
